<script type="text/javascript">
    $(function () {
        var gsid = $("#skf_gs_id").val();
        var pjsflxType = $("#pj_search_pjsflx").val();
        var khhMc = $("#pjgl_search_khhId").val();
        var pjhm = $("#pjgl_search_pjhm").val();

        if(pjsflxType==0){
            $("#pj_search_grid").edatagrid({
                url:$.webPath() + "/zjgl/pjgl/pjglwsyList?gsId="+gsid+"&&pjsflxType="+pjsflxType,
                toolbar:"#toolbar_jkd_search",
                fitColumns:true,
                singleSelect:false,
                pagination:true,
                fit:true,
                rownumbers:true,
                columns: [
                    [
                        {field: 'checked', checkbox: true},
                        {field:'id', title:'ID', hidden:true},
                        {field:'pjhm', title:'票据号码', width:20,align: 'center'},
                        {field:'yscpyh', title:'银行名称', width:25,align: 'center'},
                        {field:'dqje', title:'票据金额', width:15, formatter:function(value){
                            var sl = formatJe2(value,",");
                            return sl;
                        }   ,align: 'right'
                        },
                        {field:'dqr', title:'到期日', width:20,align: 'center'},
                        {field:'bz', title:'备注', width:20,align: 'center'}

                    ]
                ]
            });
        }else{
            $("#pj_search_grid").edatagrid({
                url:$.webPath() + "/zjgl/pjgl/pjglwsyList?gsId="+gsid+"&&pjsflxType="+pjsflxType,
                toolbar:"#toolbar_jkd_search",
                fitColumns:true,
                singleSelect:false,
                pagination:true,
                fit:true,
                rownumbers:true,
                columns: [
                    [
                        {field: 'checked', checkbox: true},
                        {field:'id', title:'ID', hidden:true},
                        {field:'pjhm', title:'票据号码', width:20,align: 'center'},
                        {field:'yfcpyh_qc', title:'银行名称', width:25,align: 'center'},
                        {field:'dqje', title:'票据金额', width:15, formatter:function(value){
                            var sl = formatJe2(value,",");
                            return sl;
                        }   ,align: 'right'
                        },
                        {field:'dqr', title:'到期日', width:20,align: 'center'},
                        {field:'bz', title:'备注', width:20,align: 'center'}

                    ]
                ]
            });
        }



    //查询按钮
    $("#btn_pj_search_search").click(function () {
        pj_search_search();
    });

        //查询票据
        function pj_search_search() {
            var khhMc = $("#pjgl_search_khhId").val();
            var pjhm = $("#pjgl_search_pjhm").val();
            $('#pj_search_grid').datagrid('load',
                    {
                        khhMc: khhMc,
                        pjhm:pjhm
                    }
            );
        }


    $("#pj_search_pjsflx").change(function (oldValue,newValue) {
        var gsid = $("#skf_gs_id").val();
        var pjsflxType = $("#pj_search_pjsflx").val();
        var khhMc = $("#pjgl_search_khhId").val();
        var pjhm = $("#pjgl_search_pjhm").val();
        if(pjsflxType==0){
            $("#pj_search_grid").edatagrid({
                url:$.webPath() + "/zjgl/pjgl/pjglwsyList?gsId="+gsid+"&&pjsflxType="+pjsflxType,
                toolbar:"#toolbar_jkd_search",
                fitColumns:true,
                singleSelect:false,
                pagination:true,
                fit:true,
                rownumbers:true,
                columns: [
                    [
                        {field: 'checked', checkbox: true},
                        {field:'id', title:'ID', hidden:true},
                        {field:'pjhm', title:'票据号码', width:20,align: 'center'},
                        {field:'yscpyh', title:'银行名称', width:25,align: 'center'},
                        {field:'dqje', title:'票据金额', width:15, formatter:function(value){
                            var sl = formatJe2(value,",");
                            return sl;
                        }   ,align: 'right'
                        },
                        {field:'dqr', title:'到期日', width:20,align: 'center'},
                        {field:'bz', title:'备注', width:20,align: 'center'}

                    ]
                ]
            });
        }else{
            $("#pj_search_grid").edatagrid({
                url:$.webPath() + "/zjgl/pjgl/pjglwsyList?gsId="+gsid+"&&pjsflxType="+pjsflxType,
                toolbar:"#toolbar_jkd_search",
                fitColumns:true,
                singleSelect:false,
                pagination:true,
                fit:true,
                rownumbers:true,
                columns: [
                    [
                        {field: 'checked', checkbox: true},
                        {field:'id', title:'ID', hidden:true},
                        {field:'pjhm', title:'票据号码', width:20,align: 'center'},
                        {field:'yfcpyh_qc', title:'银行名称', width:25,align: 'center'},
                        {field:'dqje', title:'票据金额', width:15, formatter:function(value){
                            var sl = formatJe2(value,",");
                            return sl;
                        }   ,align: 'right'
                        },
                        {field:'dqr', title:'到期日', width:20,align: 'center'},
                        {field:'bz', title:'备注', width:20,align: 'center'}

                    ]
                ]
            });
        }

    });
    })

</script>
<div id="layout_pj_search" class="easyui-layout" data-options="fit:true" style="width: 100%;height: 100%">
    <div data-options="region:'center'" style="width: 100%;height:100%">
        <div id="toolbar_jkd_search">
            <div class="textcon">
                <table class="tb">
                    <tr>
                        <th>票据收付类型：</th>
                        <td><select id="pj_search_pjsflx" class=" input-text" style="width: 80px">
                            <option value="0" selected="selected">应收票据</option>
                            <option value="1">应付票据</option>
                        </select>
                        <th>票据号码：</th>
                        <td><input id="pjgl_search_pjhm" class="input-text" value="" type="text" style="width:120px;" ></td>
                        <th>账户名称：</th>
                        <td><input id="pjgl_search_khhId" type="text" value="" class=" input-text" style="width:150px;" /></td>
                        <td style=" padding-left:25px;"><input id="btn_pj_search_search" type="button" value="" class="submit"/></td>
                    </tr>
                </table>
            </div>
        </div>
        <table id="pj_search_grid"></table>
    </div>
</div>